package com.du.javaweb.servlet;

import javax.servlet.http.Cookie;

/**
 * @author : DuJiabao
 * @Date : 2021/3/28 15:38
 * @Project : java-web
 * @File : null.java
 * @Desc :
 */
public class CookieUtils {
  /**
   * 查找指定名字的Cookie
   * @param cookieName
   * @param cookies
   * @return
   */
  public static Cookie findCookie(String cookieName, Cookie[] cookies) {
    if (cookieName == null || cookies == null || cookies.length == 0)
      return null;

    for (Cookie cookie : cookies) {
      if (cookieName.equals(cookie.getName()))
        return cookie;
    }
    return null;
  }
}
